import { EntityTypeEnum, InputTypeEnum } from './Enum'
// 二维向量
export interface IVec2 {
  x: number
  y: number
}
// 角色
export interface IActor {
  id: number
  hp: number
  nickname: string
  position: IVec2
  direction: IVec2
  type: EntityTypeEnum
  weaponType: EntityTypeEnum
  bulletType: EntityTypeEnum
}
// 子弹
export interface IBullet {
  id: number
  owner: number
  position: IVec2
  direction: IVec2
  type: EntityTypeEnum
}
// 数据库集合
export interface IState {
  actors: IActor[]
  bullets: IBullet[]
  nextBulletID: number
  seed: number
}

// 客户端输入
export type IClientInput = IActorMove | IWeaponShoot | ITimePast

// 角色移动
export interface IActorMove {
  id: number
  type: InputTypeEnum.ActorMove
  direction: IVec2
  dt: number
}
// 子弹射击
export interface IWeaponShoot {
  owner: number
  type: InputTypeEnum.WeaponShoot
  position: IVec2
  direction: IVec2
}

// 时间流逝
export interface ITimePast {
  type: InputTypeEnum.TimePast
  dt: number
}

// 事件注册
export interface IItem {
  cb: Function
  ctx: unknown
}
// api返回
export interface ICallApiret<T> {
  success: boolean
  res?: T
  error?: Error
}
